<?php
$dis_id=3;
include("../../inc/conn.inc");
include("../islogin.php");
if($_POST['act_xg']){
 $_POST["p_title"]=delwords($_POST["p_title"]);
  $_POST["info"]=delwords($_POST["info"]);
  $_POST["pinpai"]=delwords($_POST["pinpai"]);
  $_POST["xinghao"]=delwords($_POST["xinghao"]);
 
   	    $c_rs_1=mysql_query("select * from pf_catalog where id='$_POST[catalog_1]'");
	    $c_row_1=mysql_fetch_array($c_rs_1);
	    $c_rs_2=mysql_query("select * from pf_catalog where id='$_POST[catalog_2]'");
	    $c_row_2=mysql_fetch_array($c_rs_2);
		$c_rs_3=mysql_query("select * from pf_catalog where id='$_POST[catalog_3]'");
	    $c_row_3=mysql_fetch_array($c_rs_3);
		
	    $catalog_1=($_POST[catalog_1])?$_POST[catalog_1]:0;
	    $catalog_2=($_POST[catalog_2])?$_POST[catalog_2]:0;
		$catalog_3=($_POST[catalog_3])?$_POST[catalog_3]:0;
		$is_huodong=($_POST[is_huodong])?$_POST[is_huodong]:0;

@mysql_query("update pf_list set p_title='$_POST[p_title]',catalog_id1='$catalog_1',catalog_1='$c_row_1[cat_name]',catalog_id2='$catalog_2',catalog_2='$c_row_2[cat_name]',catalog_id3='$catalog_3',catalog_3='$c_row_3[cat_name]',p_pinpai='$_POST[pinpai]',p_xinghao='$_POST[xinghao]',p_price='$_POST[price]',p_shuliang='$_POST[shuliang]',p_guige='$_POST[guige]',p_baozhuang='$_POST[baozhuang]',p_cailiao='$_POST[cailiao]',p_chandi='$_POST[chandi]',p_renzheng='$_POST[renzheng]',p_jiaohu='$_POST[jiaohu]',p_paytype='$_POST[paytype]',p_yunshu='$_POST[yunshu]',p_yunfei='$_POST[yunfei]',picture='$_POST[picture]',p_info='$_POST[info]',is_huodong='$is_huodong',hd_price='$_POST[hd_price]',hd_time='$_POST[hd_time]',p_cl=0 where id='".$_POST['iid']."'");


echo "<script>alert('修改成功');location='".$_POST['urls']."';</script>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心-三帝贸易网</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/left.js" charset="gb2312"></script>
<script type='text/javascript' src="../js/time.js" charset="gb2312"></script>
<body>
<script language = "JavaScript">    
<?php
$rs1=mysql_query("select * from pf_catalog order by id asc");
?>
var onecount;
onecount=0;
subcat=new Array();
<?php
$count1=0;
while($row1=mysql_fetch_array($rs1)){?>
subcat[<?=$count1?>]=new Array("<?=$row1[cat_name]?>","<?=$row1[cat_id]?>","<?=$row1[id]?>");
<?php
$count1=$count1+1;}?>
onecount=<?=$count1?>;  
//联动函数    
function changelocation(locationid){   
   document.form1.catalog_2.length=0;     
   var locationid=locationid;   
   var i;   
   for(i=0;i<onecount;i++){   
       if(i==0){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option("--二级分类--","");
		  }   
       if(subcat[i][1]==locationid){     
          document.form1.catalog_2.options[document.form1.catalog_2.length]=new Option(subcat[i][0],subcat[i][2]);   
          }                   
    }   
}

function changelocation2(locationid2)   
{   
document.form1.catalog_3.length=0;     
var locationid2=locationid2;   
var i2;   
for (i2=0;i2<onecount;i2++){   
     if(i2==0){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option("--三级分类--","");     
         }   
     if(subcat[i2][1]==locationid2){     
         document.form1.catalog_3.options[document.form1.catalog_3.length]=new Option(subcat[i2][0],   subcat[i2][2]);   
         }                   
     }   
}
</script>
<div id="mian">
<?php include("../inc/top.php");?>
<div class="top1"><span>您当前位置：<a href="../index.php" class="dh">会员助手</a> &gt;&gt; 批发市场 &gt;&gt; 修改批发市场</span></div>
<div class="left">
<?php include("../inc/left.php");?>
</div>
<div class="right">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
   <TR>
     <TD height="40" bgcolor="#EFF6FF" style="font-size:18px;font-weight:bold;padding-left:8px;">修改批发市场信息</TD>
   </TR>
</TABLE>
<br>
<?php 
$j_rs=@mysql_query("select * from pf_list where id='".$_GET['xg_id']."' and member_id='".$_COOKIE['user_id']."'");
$j_row=@mysql_fetch_array($j_rs);
?>
<TABLE width="100%" border="0" cellpadding="0" cellSpacing="1" bgcolor="#C1DCF5">
        <TBODY>
        <form method="post" action="" name="form1" onSubmit="return checkform()">
          <TR>
            <td width="17%" height="25" align="center" bgcolor="#EFF6FF">标题&nbsp;<font color="#FF0000">*</font></td>
            <TD width="83%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="p_title" id="p_title" type="text" size="50" maxlength="120" value="<?=$j_row["p_title"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">目录<span style="padding-left:4px;line-height:35px;">&nbsp;<font color="#FF0000">*</font></span></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;line-height:35px;"><select name="catalog_1" id="catalog_1" onChange="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
 <option value="">--选择大类--</option>   
<?php
$rrs=mysql_query("select * from pf_catalog where cat_id=0 order by id asc");    
while($rrow=mysql_fetch_array($rrs)){   
?>     
 <option value="<?=$rrow[id]?>" <?php if($j_row[catalog_id1]==$rrow[id]){echo "selected";}?>><?=$rrow[cat_name]?></option><?php }?>
</select>&nbsp;<select name="catalog_2" id="catalog_2" onFocus="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
  <option value="">--选择二级分类--</option>
        <?php 
		 $rrs2=mysql_query("select * from pf_catalog where id='$j_row[catalog_id2]' order by id asc");
		 while($rrow2=mysql_fetch_array($rrs2)){
		?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
		<?php }?>
</select>&nbsp;<select name="catalog_3" id="catalog_3" onFocus="changelocation2(document.form1.catalog_2.options[document.form1.catalog_2.selectedIndex].value)">   
  <option value="" selected>--选择三级分类--</option>
        <?php 
		   $rrs2=mysql_query("select * from pf_catalog where id='$j_row[catalog_id3]' order by id asc");
		   while($rrow2=mysql_fetch_array($rrs2)){
		?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
		<?php }?>
</select></TD>
          </TR>		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">描述&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><textarea name="info" id="info" cols="70" rows="20"><?=$j_row["p_info"]?></textarea>
            <br>
            <font color="#FF0000">警告：</font>请不要添加<font color="#FF0000">公司电话</font>和贵<font color="#FF0000">公司网址</font>，否则我们直接删除该信息。<br></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">图片</td>
            <TD bgcolor="#F9F9F9" style="padding:4px;line-height:30px;"><input name="picture" id="picture" type="text" size="35" maxlength="100" value="<?=$j_row["picture"]?>">&nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片">
              (建议图片长宽：270*240)<br>
              <input type="button" onClick="window.open ('/member/photo/info.php', 'newwindow', 'height=500, width=600, top=0, left=250, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no')" value="选择已上传的图片"></TD>
          </TR>
		  <TR>
            <td height="25" colspan="2" align="left" bgcolor="#EFF6FF"><STRONG>参数<font color="#FF0000">(请认真完善以下资料，否则您的信息将直接删除)</font></STRONG></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品品牌&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="pinpai" id="pinpai" type="text" size="20" maxlength="20"  value="<?=$j_row["p_pinpai"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品型号&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="xinghao" id="xinghao" type="text" size="20" maxlength="20" value="<?=$j_row["p_xinghao"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">批发价格&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="price" id="price" type="text" size="20" maxlength="20" value="<?=$j_row["p_price"]?>">
            元<font color="red">（请写实际批发价格）</font></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">起批数量&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="shuliang" id="shuliang" type="text" size="20" maxlength="20" value="<?=$j_row["p_shuliang"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品规格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="guige" id="guige" type="text" size="20" maxlength="20" value="<?=$j_row["p_guige"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品包装</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="baozhuang" id="baozhuang" type="text" size="20" maxlength="20" value="<?=$j_row["p_baozhuang"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品材料</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="cailiao" id="cailiao" type="text" size="20" maxlength="20" value="<?=$j_row["p_cailiao"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品产地</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="chandi" id="chandi" type="text" size="20" maxlength="20" value="<?=$j_row["p_chandi"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">商品认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="renzheng" id="renzheng" type="text" size="20" maxlength="20" value="<?=$j_row["p_renzheng"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">交货时间&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="jiaohu" id="jiaohu" type="text" size="20" maxlength="20" value="<?=$j_row["p_jiaohu"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">付款方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="paytype" id="paytype" type="text" size="20" maxlength="20" value="<?=$j_row["p_paytype"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运输方式&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="yunshu" id="yunshu" type="text" size="20" maxlength="20" value="<?=$j_row["p_yunshu"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">运费承担&nbsp;<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="yunfei" id="yunfei" type="text" size="20" maxlength="20" value="<?=$j_row["p_yunfei"]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动</td>
            <td height="25" align="left" bgcolor="#F9F9F9"><input type="radio" name="is_huodong" value="1" <?php if($j_row[is_huodong]==1){echo "checked";}?>>是<input type="radio" name="is_huodong" value="0" <?php if($j_row[is_huodong]==0){echo "checked";}?>>否&nbsp;&nbsp;&nbsp;<font color="#FF0000">选择活动，下面活动价格和活动时间必须填写</font></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动价格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_price" id="hd_price" type="text" size="20" maxlength="20" value="<?=$j_row["hd_price"]?>">
            元（请写数字）</TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">活动时间</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="hd_time" id="hd_time" type="text" size="20" maxlength="20" onClick="setDay(this);" value="<?=$j_row["hd_time"]?>">
            时间格式：0000-00-00 00:00:00</TD>
          </TR>			  		  		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value="提交"><INPUT type="hidden" value="ok" name="act_xg"><input type="hidden" name="urls" value="<?=$_SERVER['HTTP_REFERER']?>"><input type="hidden" name="iid" value="<?=$j_row[id]?>"></TD>
          </TR>
 </form>                
</TABLE>
</div>
<div class="onl"></div>
<?php include("../inc/foot.php");?>

</div>
</body>
</html>
<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
   if($("p_title").value==""){
      alert("标题不能为空");
      $("p_title").focus();
      return false;
   }
   if($("catalog_1").value==""){
      alert("请选择目录");
      $("catalog_1").focus();
      return false;
   }
   if($("catalog_2").value==""){
      alert("请选择二级目录");
      $("catalog_2").focus();
      return false;
   }

   if($("info").value==""){
      alert("描述不能为空");
      $("info").focus();
      return false;
   }
   
   if($("pinpai").value==""){
      alert("商品品牌不能为空");
      $("pinpai").focus();
      return false;
   }  
   if($("xinghao").value==""){
      alert("商品型号不能为空");
      $("xinghao").focus();
      return false;
   }   
   if($("price").value==""){
      alert("批发价格不能为空");
      $("price").focus();
      return false;
   }
   if($("shuliang").value==""){
      alert("批发数量不能为空");
      $("shuliang").focus();
      return false;
   } 
   if($("jiaohu").value==""){
      alert("交货时间不能为空");
      $("jiaohu").focus();
      return false;
   }  
   if($("paytype").value==""){
      alert("付款方式不能为空");
      $("paytype").focus();
      return false;
   } 
   if($("yunshu").value==""){
      alert("运输方式不能为空");
      $("yunshu").focus();
      return false;
   }
   if($("yunfei").value==""){
      alert("运费承担不能为空");
      $("yunfei").focus();
      return false;
   }
   if($("is_huodong").checked){
      if($("hd_price").value==""){
	    alert("活动价格不能为空");
        $("hd_price").focus();
        return false;
	  }
	  if($("hd_time").value==""){
	    alert("活动时间不能为空");
        $("hd_time").focus();
        return false;
	  }
   }   
           
      
}
</script>
